import { Module } from '@nestjs/common';
import { UserClientController } from './user-client.controller';
import { UserClientService } from './user-client.service';
import { DbModule } from './db/db.module';
import { ConfigureModule, ConfigureService } from '@app/configure';
import { CacheModule } from '@app/cache';
import { UserModule } from './http/user/user.module';
import { LoginModule } from './http/login/login.module';
import { APP_GUARD } from '@nestjs/core';
import { AuthGuard } from './guard/auth/auth.guard';
import { SysConfigRepositoryModule } from '@app/db/common/sys-config-repository/sys-config-repository.module';
import config from './config'
import { UploaderModule } from '@app/uploader';
import { SYS_CONFIG } from 'constant/SYS_CONFIG';
import { SmsModule } from './sms/sms.module';
import { UploadModule } from './http/upload/upload.module';
import { ImclientModule } from '@app/imclient';
import { YunxincallbackModule } from './http/yunxincallback/yunxincallback.module';
import { UserGroupModule } from './http/user-group/user-group.module';

@Module({
	imports: [
		ConfigureModule.forRoot(config),
        DbModule,
		CacheModule,
		ImclientModule.forRootAsync({
			inject : [ConfigureService],
			useFactory : async (config:ConfigureService) => {
				return {
					appKey: config.get('im.AppKey'),
					appSecret: config.get('im.AppSecret'),
				}
			},
		}),
		UploaderModule.forRootAsync({
			inject : [ConfigureService],
			useFactory : async (config:ConfigureService) => {
				return {
					...config.get('upload')
				}
			},
		}),
		SysConfigRepositoryModule,
        UserModule,
		LoginModule,
		SmsModule,
		UploadModule,
		YunxincallbackModule,
		UserGroupModule,
	],
	controllers: [UserClientController],
	providers: [UserClientService, {provide : APP_GUARD, useClass : AuthGuard}],
})
export class UserClientModule {}
